import 'package:flutter/material.dart';
// import 'package:flutter_alpha_player_plugin/alpha_player_view.dart';
import 'package:flutter_svgaplayer3/flutter_svgaplayer3.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';

import 'gift_prop_animation_logic.dart';

class GiftPropAnimationPage extends StatefulWidget {
  const GiftPropAnimationPage({Key? key}) : super(key: key);

  @override
  State<GiftPropAnimationPage> createState() => _GiftPropAnimationPageState();
}

class _GiftPropAnimationPageState extends State<GiftPropAnimationPage>
    with SingleTickerProviderStateMixin {
  final GiftPropAnimationLogic logic = Get.put(GiftPropAnimationLogic());

  @override
  void initState() {
    logic.animationController = SVGAAnimationController(vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<GiftPropAnimationLogic>(builder: (l) {
      if (logic.playing) {
        return logic.isSvga
            ? SVGAImage(logic.animationController)
            // : const IgnorePointer(child: AlphaPlayerView());
            : SizedBox();
      } else {
        return const SizedBox();
      }
      // return LStack([
      //   SVGAImage(logic.animationController),
      //   const IgnorePointer(child: AlphaPlayerView())
      // ]);
    });
  }

  @override
  void dispose() {
    Get.delete<GiftPropAnimationLogic>();
    super.dispose();
  }
}
